package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.MoreLikeBean;
import com.lwj.liwanjia.impl.MoreLikeView;
import com.lwj.liwanjia.model.MoreLikeModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/27.
 */

public class MoreLikePresenter {
    private MoreLikeModel moreLikeModel;
    private MoreLikeView moreLikeView;

    public MoreLikePresenter(MoreLikeView moreLikeView) {
        this.moreLikeView = moreLikeView;
        moreLikeModel = new MoreLikeModel();
    }

    public void getMoreLike(String token,int page) {
        if (moreLikeView != null) {
            moreLikeModel.getMoreLike(token,page, new Subscriber<MoreLikeBean>() {
                @Override
                public void onCompleted() {
                    moreLikeView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    moreLikeView.showError((Exception) e);
                    moreLikeView.hideProgress();
                }

                @Override
                public void onNext(MoreLikeBean moreLikeBean) {
                    moreLikeView.getMoreLike(moreLikeBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    moreLikeView.showProgress();
                }
            });
        }
    }
}
